﻿@model SIG.Model.Identity.Role

@{
    ViewBag.PageTitle = "创建" + SettingsManager.Role.ModelName;
    ViewBag.Title = ViewBag.PageTitle + "_安全";
}

@section leftNav{
    @Html.Partial("_NavForSecurity")
}


<div class="main-content">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                <span class="glyphicon glyphicon-pencil"></span>  @ViewBag.PageTitle
            </h3>
        </div>
        <div class="panel-body">
            @using (Ajax.BeginForm("Create", null, new AjaxOptions()
            {

                OnSuccess = "updateSuccess",
                OnBegin = "onBegin",
                OnComplete = "onComplete"

            }, new { @class = "form-horizontal", role = "form" }))
            {
                @Html.AntiForgeryToken()

                <div class="form-horizontal">

                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                    <div class="form-group">
                        @Html.LabelFor(model => model.RoleName, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-10">
                            @Html.EditorFor(model => model.RoleName, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.RoleName, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.Description, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-10">
                            @Html.TextAreaFor(model => model.Description, new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Description, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-disk"></span> 保存</button>
                            <a href="@Url.Action("Index")" class="btn btn-default"><span class="glyphicon glyphicon-menu-left"></span> 返回</a>
                        </div>
                    </div>
                </div>
            }

            <div class="loading" id="divLoading">
                <div>
                    <div class="c1"></div>
                    <div class="c2"></div>
                    <div class="c3"></div>
                    <div class="c4"></div>
                </div>

            </div><!-- /.divLoading -->

        </div>
    </div>
</div>

@section Footer {
    @Scripts.Render("~/bundles/jqueryval")
    <script>
        function onBegin() {
            $("#divLoading").show();
        }
        function onComplete() {
            $("#divLoading").hide();
        }
        function updateSuccess(data) {
            var modelName = "@SettingsManager.Role.ModelName";
            //  console.log(data.Oicq);
            if (data) {
                //  debugger;
                toastr.success(modelName + '已添加成功！', '@ViewBag.PageTitle')
            } else {
                toastr.error(modelName + '添加失败！', '@ViewBag.PageTitle')
            }
        }

        $(function () {

            //当前菜单
            $('.mainmenu>li:nth-of-type(1)').addClass('nav-open').find('.submenu li:nth-of-type(4) a').addClass('active');
        });
    </script>
}